package com.wasion.gydpe.ice;

public class Ice_Thread implements Runnable {

	private CMultiPeer peer = null;

	private static InitServer instance = null;

	public synchronized static InitServer getInstance() {
		if (instance == null)
			instance = new InitServer();
		return instance;

	}

	public void run() {

		try {
			String proxyString = "";
			String evt = "";
			String server_evt = "";
			String server_port = "";
			TestProperties ec = TestProperties.getInstance();
			if (ec == null) {
				System.out.println();
				// log.loger.error("打开 IceComm.properties 失败");
			} else {
				evt = ec.getPropertyValue("/IceComm.properties",
						"Communication.Endpoints");
				server_evt = ec.getPropertyValue("/IceComm.properties",
						"ServerProxy.server_event");
				server_port = ec.getPropertyValue("/IceComm.properties",
						"ServerProxy.server_port");
				proxyString = ec.getPropertyValue("/IceComm.properties",
						"Remote.Proxy");
				/*
				 * Ice_thread = ec.getPropertyValue("/IceComm.properties",
				 * "Remote.DefaultPort");
				 */
			}

			Ice.Communicator commFactory = Ice.Util.initialize();
			IceWrapper comm = new IceWrapper(commFactory, server_evt,
					server_port);
			peer = new CMultiPeer(comm);
			ReceiveMessage receiveMessage = new ReceiveMessage();
			peer.init(evt, receiveMessage, proxyString, proxyString);
			comm.getCommunicator().waitForShutdown();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
